package com.ruoyi.system.service.impl;

import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.system.domain.RecordSearch;
import com.ruoyi.system.domain.vo.BarChartVo;
import com.ruoyi.system.mapper.RecordSearchMapper;
import com.ruoyi.system.service.IRecordSearchService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 搜索量记录Service业务层处理
 *
 * @author admin
 * @date 2022-03-21
 */
@Service
public class RecordSearchServiceImpl implements IRecordSearchService {
    @Autowired
    private RecordSearchMapper recordSearchMapper;

    /**
     * 查询搜索量记录
     *
     * @param searchId 搜索量记录主键
     * @return 搜索量记录
     */
    @Override
    public RecordSearch selectRecordSearchBySearchId(Long searchId) {
        return recordSearchMapper.selectRecordSearchBySearchId(searchId);
    }

    /**
     * 查询搜索量记录列表
     *
     * @param recordSearch 搜索量记录
     * @return 搜索量记录
     */
    @Override
    public List<RecordSearch> selectRecordSearchList(RecordSearch recordSearch) {
        return recordSearchMapper.selectRecordSearchList(recordSearch);
    }

    /**
     * 新增搜索量记录
     *
     * @param recordSearch 搜索量记录
     * @return 结果
     */
    @Override
    public int insertRecordSearch(RecordSearch recordSearch) {
        recordSearch.setCreateBy(SecurityUtils.getUsername());
        recordSearch.setCreateTime(DateUtils.getNowDate());
        return recordSearchMapper.insertRecordSearch(recordSearch);
    }

    /**
     * 修改搜索量记录
     *
     * @param recordSearch 搜索量记录
     * @return 结果
     */
    @Override
    public int updateRecordSearch(RecordSearch recordSearch) {
        recordSearch.setUpdateTime(DateUtils.getNowDate());
        return recordSearchMapper.updateRecordSearch(recordSearch);
    }

    /**
     * 批量删除搜索量记录
     *
     * @param searchIds 需要删除的搜索量记录主键
     * @return 结果
     */
    @Override
    public int deleteRecordSearchBySearchIds(Long[] searchIds) {
        return recordSearchMapper.deleteRecordSearchBySearchIds(searchIds);
    }

    /**
     * 删除搜索量记录信息
     *
     * @param searchId 搜索量记录主键
     * @return 结果
     */
    @Override
    public int deleteRecordSearchBySearchId(Long searchId) {
        return recordSearchMapper.deleteRecordSearchBySearchId(searchId);
    }

    // 状态图、饼状图数据查询
    @Override
    public List<BarChartVo> selectBarChartVoList(BarChartVo barChartVo) {
        return recordSearchMapper.selectBarChartVoList(barChartVo);
    }
}
